﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Medicae_Toolkit
{
    public partial class Party : Form
    {
        public Medicae PForm;
        public Party(Medicae m)
        {
            InitializeComponent();
            PForm = m;
            UpdateList();
        }

        private void Party_Load(object sender, EventArgs e)
        {

        }

        public void UpdateList()
        {
            listBox1.Items.Clear();
            listBox1.Items.AddRange(PForm.CurrentParty.ToArray());
            PForm.UpdateList();
        }

        private void editButton_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem == null)
                return;

            (new CharEditor(this, (Character)listBox1.SelectedItem, false)).Show();
               
        }

        private void newButton_Click(object sender, EventArgs e)
        {
            (new CharEditor(this, new Character(), true)).Show();
        }

        private void closeButton_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void Party_FormClosed(object sender, FormClosedEventArgs e)
        {
            PForm.UpdateList();
            PForm.Show();
            PForm.BringToFront();
        }
    }
}
